package tech.runchen.gz5055.oms.modules.openapi.controller;

import cn.hutool.core.bean.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import tech.runchen.gz5055.oms.common.utils.Result;
import tech.runchen.gz5055.oms.modules.openapi.form.AddressForm;
import tech.runchen.gz5055.oms.modules.system.entity.AddressEntity;
import tech.runchen.gz5055.oms.modules.system.service.IAddressService;

import java.util.List;

/**
 * @author zzj
 */
@RestController
@RequestMapping("/openapi/address")
public class OpenApiAddressController {

    @Autowired
    private IAddressService addressService;
//    @Autowired
//    private JnaLibraryUtils jnaLibraryUtils;

    @PostMapping("/push")
    public Result push(@Validated @RequestBody List<AddressForm> addressList) {
        for (AddressForm form : addressList) {
            AddressEntity address = addressService.queryInfoByAddressId(form.getAddressId());
            if (address == null) {
                address = new AddressEntity();
                BeanUtil.copyProperties(form, address);
                addressService.saveAddress(address);
            } else {
                BeanUtil.copyProperties(form, address);
                addressService.updateAddress(address);
            }
        }
        return Result.success("操作成功");
    }

//    @GetMapping("/test")
//    public Result test(@RequestParam Map<String, Object> params) {
//
//        String name = (String) params.get("name");
//        String name1 = (String) params.get("name1");
//
//        Map<String, String> fpData = new HashMap<>();
//        fpData.put("zzj1", "AwFgGYNh+AbwAuACwALAAoACgAKAAoACgAKAAoACgAKAAoACgALABgAAAACDAAlDTUIfBAEZHwJCBSvePYurnlqQrJ5BFxWeXSPDnkQvQ/5DuYceLDrFvjW8B75iPMheSw9VH2cSgZ9PGkCfPaQAfyQrLL9OsxofJjSA/y+xAPwcuey8T4lVfTEtld1SjCwbOo/VmzwS6zsgN1SbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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gAKAAoACgAKAAoACwALgAuAC4ALwBgAAAAB5AyhRQzwFAAAbGQJPilSeXZmTPmcu6N5Rs0/eIbkm3kQ55p5YQE2eOUPQfiuN6d8/D1LfSZTTPzYYkr8rHWe/IKAhn00gkZ8YoegfMqenX1A9Tn9NrNCcJJPRHTsUad1TpmZdYauQelUjT1slGGuVJhiUtVsvp3MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=");
//        int result = jnaLibraryUtils.matchTemplate(fpData.get(name), fpData.get(name1));
//
//        return Result.success(result);
//    }
}
